package org.cainiao.oauth2.client.springboot;

import org.cainiao.oauth2.client.core.dao.service.CnClientRegistrationMapperService;
import org.cainiao.oauth2.client.springboot.oauth2client.CNAuthorizationCenterOAuth2ClientRegistrationRepositoryConfiguration;
import org.cainiao.oauth2.client.springboot.oauth2client.CNAuthorizationCenterOAuth2WebSecurityConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.oauth2.client.registration.ClientRegistration;

/**
 * <br />
 * <p>
 * Author: Cai Niao(wdhlzd@163.com)<br />
 */
@AutoConfiguration(before = OAuth2ClientAutoConfiguration.class)
@ConditionalOnProperty(name = "cn.oauth2.client.enable", havingValue = "true", matchIfMissing = true)
@ConditionalOnClass({EnableWebSecurity.class, ClientRegistration.class})
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@Import({
    CNAuthorizationCenterOAuth2ClientRegistrationRepositoryConfiguration.class,
    CNAuthorizationCenterOAuth2WebSecurityConfiguration.class
})
@ComponentScan(basePackageClasses = CnClientRegistrationMapperService.class)
public class CNAuthorizationCenterOAuth2ClientAutoConfiguration {
}
